package com.wkf.truck.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wkf.truck.model.Orders;
import com.wkf.truck.dao.OrdersDao;
import com.wkf.truck.service.OrdersService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import javax.annotation.Resource;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author lxb
 * @since 2021-02-14
 */
@Service
public class OrdersServiceImpl extends ServiceImpl<OrdersDao, Orders> implements OrdersService {


    @Override
    public IPage getAllOrders(Orders orders) {

        Page<Orders> page = new Page<>(orders.getPageNum(), orders.getPageSize());
        QueryWrapper<Orders> wrapper = new QueryWrapper<>();

        if(!StringUtils.isEmpty(orders.getTruckType())){
            wrapper.like("truck_type",orders.getTruckType());
        }
        if(!StringUtils.isEmpty(orders.getContactPerson())){
            wrapper.like("contact_person",orders.getContactPerson());
        }
        IPage<Orders> result = this.page(page, wrapper);

        return result;
    }
}
